
package com.example.quicklaunch;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class AppDataBaseHelper extends SQLiteOpenHelper {
    private final static String DATABASE_NAME = "app_list.db";
    private final static int VERSION = 1;
    // Table app
    public static final String TABLE_APP = "app";
    public static final String APP_CLOUMN_ID = "_id";
    public static final String APP_CLOUMN_PACKAGE = "package";
    public static final String APP_CLOUMN_CLASS_NAME = "class_name";
    public static final String APP_CLOUMN_LABEL = "label";
    public static final String APP_CLOUMN_LOOKUP = "lookup";

    public AppDataBaseHelper(Context context) {
        this(context, DATABASE_NAME, null, VERSION);
    }

    private AppDataBaseHelper(Context context, String name, CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String createTableSql = "CREATE TABLE " + TABLE_APP
                + "(" + APP_CLOUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
                + APP_CLOUMN_PACKAGE + " STRING NOT NULL,"
                + APP_CLOUMN_LABEL + " STRING NOT NULL,"
                + APP_CLOUMN_CLASS_NAME + " STRING NOT NULL,"
                + APP_CLOUMN_LOOKUP + " STRING NOT NULL)";
        db.execSQL(createTableSql);
        db.execSQL("CREATE INDEX lookupIndex on " + TABLE_APP + "(" + APP_CLOUMN_LOOKUP + ")");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }

}
